{extend name="public:adminbase" /}

{block name="content"}


<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-header">
          <h3>{$title}</h3>
        </div>

        <div class="card-toolbar clearfix">
          <div class="toolbar-btn-action">
            <a class="btn btn-primary m-r-5" href="javascript:;" onclick="openframe('{:url('AdminRbac/addgroup')}')"><i class="mdi mdi-plus"></i> 新增</a>
            <button class="btn btn-success m-r-5" onclick="location.reload()"><i class="mdi mdi-refresh"></i> 刷新本页</button>
          </div>
        </div>

        <div class="card-body">
          
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th>
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" id="check-all"><span></span>
                    </label>
                  </th>
                  <th>ID</th>
                  <th>会员组</th>
                  <th>是否启用</th>
                  <th>注册时间</th>
                  <th>更新时间</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                {foreach $list as $v}
                <tr>
                  <td>
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" name="ids[]" value="1"><span></span>
                    </label>
                  </td>
                  <td>{$v.id}</td>
                  <td>{$v.name}</td>



                  <td>
                    {switch $v.status}
                    {case 1 }<button class="btn btn-label btn-primary btn-xs">已启用</button>{/case}
                    {case 2 }<button class="btn btn-label btn-warning btn-xs">已禁用</button>{/case}
                    {default /}<button class="btn btn-label btn-primary btn-xs">已启用</button>
                    {/switch}
                  </td>
                  <td>
                    {if !$v.create_time}
                    默认
                    {else/}
                    {$v.create_time}
                    {/if}

                  </td>
                  <td>
                      {if !$v.update_time}
                      默认
                      {else/}
                      {$v.update_time}
                      {/if}

                  </td>

                  <td>
                    <div class="btn-group">
                      <button onclick="edit(this)" class="btn btn-xs btn-default"  title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i>编辑</button>
                      <button onclick="del({$v.id})" class="btn btn-xs btn-default" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i>删除</button>
                    </div>
                  </td>
                </tr>
                {/foreach}

              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
{include file="public/afooter"}
<script>
//  新增
  function AddCate(obj) {
    var url = $(obj).attr('href');
    layer.open({
      title:"新增分类",
      type: 2,
      area: ['500px', '450px'],
      fixed: false, //不固定
      maxmin: true,
      content: url
    });
  }
//修改
  function edit(obj) {
    var url = $(obj).attr('href');
    layer.open({
      title:"修改",
      type: 2,
      area: ['500px', '450px'],
      fixed: false, //不固定
      maxmin: true,
      content: url
    });
  }
//  删除
  function del(id) {
    layer.confirm('您确定要删除吗？', {
      btn: ['确定','取消'] //按钮
    }, function(){
      var url = "{:url('AdminCate/delete')}"
      $.post(url,{id:id},function (e) {
        if(e.code != 200){
          error(e.msg);
        }else {
          success(e.msg);
          var index = parent.layer.getFrameIndex(window.name);
          setTimeout(function(){parent.layer.close(index)}, 1000);
          window.parent.location.reload();
        }
      })
    }, function(){
      layer.msg('已取消');
    });
  }
</script>

{/block}